
package cn.ljy.mes.model;

import cn.ljy.authority.model.SysFileResource;
import cn.ljy.authority.model.SysUser;
import cn.ljy.common.model.BaseModel;
import cn.ljy.common.model.validate.AddWorkValidation;
import cn.ljy.common.model.validate.UpdateWorkValidation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@ApiModel(value = "商城商品")
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, of = {"id"})
public class ShopProduct extends BaseModel {

    @ApiModelProperty(value = "商品ID", example = "28b4d848-7b7f-11f0-a22e-0250f2000002")
    @NotNull(groups = UpdateWorkValidation.class, message = "商品ID不能为空")
    private String id;

    @ApiModelProperty(value = "商品类别对象")
    @NotNull(groups = AddWorkValidation.class, message = "商品类别不能为空")
    private ShopProductType productType;

    @ApiModelProperty(value = "物料，可以为空，比如可能是充电、保养服务")
    private MesMaterial material;

    @ApiModelProperty(value = "商品名称", required = true, example = "高品质锂电池")
    @NotBlank(groups = AddWorkValidation.class, message = "商品名称不能为空")
    @Length(min = 1, max = 50, message = "商品名称长度必须在 {min} - {max} 之间")
    private String name;

    @ApiModelProperty(value = "商品简介", example = "适用于电动汽车的高性能锂电池")
    private String description;

    @ApiModelProperty(value = "产品详细描述（含富文本）", example = "容量大，循环寿命长，安全可靠...")
    private String content;

    @ApiModelProperty(value = "销售价格", required = true, example = "2500.00")
    @NotNull(groups = AddWorkValidation.class, message = "销售价格不能为空")
    @DecimalMin(value = "0.00", inclusive = false, message = "销售价格必须大于0")
    @Digits(integer = 10, fraction = 2, message = "销售价格最多10位整数、2位小数")
    private BigDecimal originalPrice;

    @ApiModelProperty(value = "促销价格/成交价格", required = true, example = "2300.00")
    @NotNull(groups = AddWorkValidation.class, message = "促销价格不能为空")
    @DecimalMin(value = "0.00", inclusive = false, message = "促销价格必须大于0")
    @Digits(integer = 10, fraction = 2, message = "促销价格最多10位整数、2位小数")
    private BigDecimal price;

    @ApiModelProperty(value = "封面图片URL", example = "https://example.com/miniev-cover.jpg")
    @NotNull(groups = AddWorkValidation.class,message="封面图片不能为空")
    private SysFileResource coverImage;//标题图片

    @ApiModelProperty(value = "商品图集（JSON数组）", notes = "JSON数组格式的图片URL列表")
    private List<String> gallery;

    @ApiModelProperty(value = "是否上架（1表示上架，但是要考虑上架时间；0表示不上架）", required = true, example = "true")
    @NotNull(groups = AddWorkValidation.class, message = "上架状态不能为空")
    private Boolean onSale;

    @ApiModelProperty(value = "排序权重", required = true, example = "100")
    @NotNull(groups = AddWorkValidation.class, message = "排序权重不能为空")
    @Min(value = 0, message = "排序权重不能小于0")
    private Integer sort;

    @ApiModelProperty(value = "产品推荐指数", example = "5")
    private Short recommendation;

    @ApiModelProperty(value = "创建管理员")
    private SysUser creator;

    @ApiModelProperty(value = "最后编辑管理员")
    private SysUser editor;

    @ApiModelProperty(value = "创建时间", example = "2025-10-15 15:00:00")
    private Date createTime;

    @ApiModelProperty(value = "更新时间", example = "2025-10-15 15:30:00")
    private Date updateTime;

    public ShopProduct(String id) {
        this.id = id;
    }
}